﻿using IDLETD.Agent;
using IDLETD.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IDLETD.FSM
{
    public class StateFollow : StateBase
    {
        public override StateEnum State => StateEnum.追击;

        private BaseGameObject onwer = null;

        private SportAgent sportAngent;
        public override SportAgent SportAgent
        {
            get { return sportAngent; }
            set { sportAngent = value; }
        }

        private CrashAgent crashAngent;
        public override CrashAgent CrashAgent
        {
            get { return crashAngent; }
            set { crashAngent = value; }
        }

        public override BaseGameObject Onwer
        {
            get { return onwer; }
            set { onwer = value; }
        }

        private BaseGameObject target;

        public override void Enter(object[] objs)
        {
            if (objs.Count() != 1) return;
            target = (BaseGameObject)objs[0];
            if (target == null) return;
        }

        public override void Excute()
        {
            if (SportAgent.Follow(target))
            {
                target.BeHit(Onwer as BulletModel);
                onwer.GoDead();
            }
        }

        public override void Leave()
        {
        }
    }
}
